<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function Accumulator(num) {
        // let this = {};
        this.value = num;
        this.read = function () {
          this.value += +prompt("num?");
        };
        // return this;
      }
      let accumulator = new Accumulator(1); // 初始值 1
      accumulator.read(); // 添加用户输入的 value
      accumulator.read(); // 添加用户输入的 value
      console.log(accumulator.value); // 显示这些值的总和
    </script>
  </body>
</html>
